/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package MemberDetails;

import Login.MySqlConnector;
import java.sql.*;

/**
 *
 * @author Bharath
 */
public class GetDatesDao {

MySqlConnector ms = new MySqlConnector();
Connection con;
PreparedStatement ps , ps1 ;
ResultSet rs , rs1;
//Vector vdates = new Vector();

public ResultSet getdates(String dfrom) throws Exception
{
   try {
   con = ms.Connect();
   String query = "SELECT name , surname , mobile, res_add, email, dob, mar_aniv  FROM registration" +
                  " WHERE DATE_FORMAT(dob, '%m%d') >= DATE_FORMAT(NOW(), '%m%d') " +
                  "AND DATE_FORMAT(dob, '%m%d') <= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL '"+dfrom+"' DAY), '%m%d') order by dob ;";
                    ps = con.prepareStatement(query);
                    System.out.println("query in getdates function is "+ps);
                    rs = ps.executeQuery();
                }catch(Exception e){ e.printStackTrace();}
          return rs;
}

public ResultSet get_aniv_dates(String dfrom) throws Exception
{
   try {
   con = ms.Connect();
   String query1 = "SELECT name , surname , mobile, res_add, email, mar_aniv  FROM registration" +
                  " WHERE DATE_FORMAT(mar_aniv, '%m%d') >= DATE_FORMAT(NOW(), '%m%d') " +
                  "AND DATE_FORMAT(mar_aniv, '%m%d') <= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL '"+dfrom+"' DAY), '%m%d') order by mar_aniv ;";
                    ps1 = con.prepareStatement(query1);
                    System.out.println("query in getdates function is "+ps1);
                    rs1 = ps1.executeQuery();
                }catch(Exception e){ e.printStackTrace();}
          return rs1;
}
}

